//
//  dBinaryViewController.m
//  Surveyer
//
//  Created by Qikun Guo on 13-7-30.
//  Copyright (c) 2013年 Tim. All rights reserved.
//

#import "dBinaryViewController.h"

@interface dBinaryViewController ()

@end

@implementation dBinaryViewController
@synthesize segmentedControl, titleLabel, currentResult, currentItem;
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    titleLabel.text = currentItem.title;
    [segmentedControl setTitle:currentItem.value1 forSegmentAtIndex:0];
    [segmentedControl setTitle:currentItem.value2 forSegmentAtIndex:1];
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
- (IBAction)valueChanged:(id)sender {
    self.editCount ++;
    if (!currentResult)
        currentResult = [[SurveyerStore defaultStore] createResultWithSurveyItem:currentItem];
    currentResult.text = [NSString stringWithFormat:@"%d", segmentedControl.selectedSegmentIndex];
    [self.delegate currentItemCompleted:self];
}
@end
